package com.matrix.java.chap_18;

/**
 * 斐波那契数
 */
public class Ex18_02 {
    public static void main(String[] args) {
        System.out.println(fib(10));
    }

    public static int fib(int n) {
        int f0 = 0;
        int f1 = 1;
        int currentFib;
        for (int i = 1; i <= n; i++) {
            currentFib = f0 + f1;
            f0 = f1;
            f1 = currentFib;
        }
        return f0;
    }
}
